/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HAPSIEAgregaArea.java
 *
 * Created on 24/01/2012, 08:44:50 PM
 */
package Interfaz;

import javax.swing.JOptionPane;


/**
 *
 * @author erika
 */
public class AgregaArea extends javax.swing.JDialog {

    /** Creates new form HAPSIEAgregaArea */
    public AgregaArea(java.awt.Dialog parent) {
        super(parent);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        textoArea = new javax.swing.JTextField();
        textoEncargado = new javax.swing.JTextField();
        botonGuardarArea = new javax.swing.JButton();
        botonCancelarArea = new javax.swing.JButton();
        botonSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(UsoHAPSIE.HAPSIEApp.class).getContext().getResourceMap(AgregaArea.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        textoArea.setText(resourceMap.getString("textoArea.text")); // NOI18N
        textoArea.setName("textoArea"); // NOI18N

        textoEncargado.setText(resourceMap.getString("textoEncargado.text")); // NOI18N
        textoEncargado.setName("textoEncargado"); // NOI18N

        botonGuardarArea.setText(resourceMap.getString("botonGuardarArea.text")); // NOI18N
        botonGuardarArea.setName("botonGuardarArea"); // NOI18N
        botonGuardarArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonGuardarAreaActionPerformed(evt);
            }
        });

        botonCancelarArea.setText(resourceMap.getString("botonCancelarArea.text")); // NOI18N
        botonCancelarArea.setName("botonCancelarArea"); // NOI18N
        botonCancelarArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonCancelarAreaActionPerformed(evt);
            }
        });

        botonSalir.setText(resourceMap.getString("botonSalir.text")); // NOI18N
        botonSalir.setName("botonSalir"); // NOI18N
        botonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(botonGuardarArea, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(botonCancelarArea, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                        .addComponent(botonSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(textoArea, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textoEncargado, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(68, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(textoArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(textoEncargado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonGuardarArea, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonCancelarArea, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void botonCancelarAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCancelarAreaActionPerformed
int response = JOptionPane.showConfirmDialog(this, "Deseas Guardar todos los cambios", "AVISO!!", JOptionPane.WARNING_MESSAGE);

   if (response == JOptionPane.NO_OPTION) {
   this.setVisible(false);
   getOwner().setVisible(true);
       
    } else if (response == JOptionPane.YES_OPTION) {
   this.setVisible(false);
   // Aqui guardamos todo los cambios
   //Todos 
   getOwner().setVisible(true);
   
   
    } else if (response == JOptionPane.CLOSED_OPTION) {
    
    }


}//GEN-LAST:event_botonCancelarAreaActionPerformed

private void botonGuardarAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGuardarAreaActionPerformed
 JOptionPane.showMessageDialog(this, "Todos los cambios han sido guardados");
}//GEN-LAST:event_botonGuardarAreaActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

   int response = JOptionPane.showConfirmDialog(this, "Deseas Guardar todos los cambios", "AVISO!!", JOptionPane.WARNING_MESSAGE);

   if (response == JOptionPane.NO_OPTION) {
    this.setVisible(false);
    getOwner().setVisible(true);
       
    } else if (response == JOptionPane.YES_OPTION) {
   this.setVisible(false);
   // Aqui guardamos todo los cambios
   //Todos 
   getOwner().setVisible(true);  
    } else if (response == JOptionPane.CLOSED_OPTION) {
   
    }

   
    
}//GEN-LAST:event_formWindowClosing

private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
 int response = JOptionPane.showConfirmDialog(this, "Deseas Guardar todos los cambios", "AVISO!!", JOptionPane.WARNING_MESSAGE);
   if (response == JOptionPane.NO_OPTION) {
    this.setVisible(false);
    getOwner().setVisible(true);
       
    } else if (response == JOptionPane.YES_OPTION) {
   this.setVisible(false);
   // Aqui guardamos todo los cambios
   //Todos 
   getOwner().setVisible(true);  
    } else if (response == JOptionPane.CLOSED_OPTION) {
    }
}//GEN-LAST:event_botonSalirActionPerformed

    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonCancelarArea;
    private javax.swing.JButton botonGuardarArea;
    private javax.swing.JButton botonSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField textoArea;
    private javax.swing.JTextField textoEncargado;
    // End of variables declaration//GEN-END:variables

    public int indice = 0;

    public int getIndice() {
        return indice;
    }

    public void setIndice(int indice) {
        this.indice = indice;
    }
}
